﻿using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using SH;

namespace MTS
{
     class mtSysManageCallback:mtOuterface<ImtSysManageCallback>
    {
        public mtSysManageCallback()
        {
            m_interfaceName = "mtSysManageCallback";
            m_nClassID = ImtSysManageCallback._classID;
        }

        protected override shErrorCode OnRequest(int nClassID, int nFuncID, string token,ref MTSSerializer sc)
        {
            shErrorCode ec = shErrorCode.sh_ec_NoInterface;

            switch (nFuncID)
            {

                case ImtSysManageCallback.SysManageUpdateCredential:
                    {
                        mtCredential crd = new mtCredential();

                        sc.serialize(crd);

                        m_pHost.RunEnv.Credential = crd;

                        ec= m_pCallback.OnUpdateCredential(crd);

                        ec = shErrorCode.sh_ec_Success;
                    }
                    break;
                case ImtSysManageCallback.SysManageStatusChange:
                    {
                        ulong status = 0;

                        sc.serialize(ref status);

                       ec = m_pCallback.OnStatusChange(status);
                    }
                    break;
                case ImtSysManageCallback.SysManageRunStatusChange:
                    {
                        uint status = 0;

                        sc.serialize(ref status);

                        m_pHost.RunEnv.RunStatus = status;

                      ec = m_pCallback.OnRunStatusChange(status);

                    }
                    break;
                case ImtSysManageCallback.SysManageGetCredential:
                    {
                        mtCredential crd = new mtCredential();

                        sc = new MTSSerializer();

                        sc.serialize(crd);

                        ec = shErrorCode.sh_ec_Success;
                    }
                    break;
                case ImtSysManageCallback.SysManageStationStatusNotify:
                    {
                        mtStationStatus info =  new mtStationStatus();

                        sc.serialize(info);

                       // m_pHost.RunEnv.UpdateGStationRunStatus(info);

                        ec = m_pCallback.OnStationStatusNotify(info);   
                    }
                    break;
                case ImtSysManageCallback.SysManagePublishGWorkFlowTask:
                    {
                        mtGWFTask wfTask = new mtGWFTask();

                        sc.serialize(wfTask);

                        m_pHost.RunEnv.UpdateGWorkFlowTask(wfTask);

                        ec = m_pCallback.OnPublishGWorkFlowTask(wfTask);
                    }
                    break;
                case ImtSysManageCallback.SysManageUpdateGWorkFlowTask:
                    {
                        mtGWFTask wfTask = new mtGWFTask();

                        sc.serialize(wfTask);

                        m_pHost.RunEnv.UpdateGWorkFlowTask(wfTask);

                        ec = m_pCallback.OnUpdateGWorkFlowTask(wfTask);
                    }
                    break;
                case ImtSysManageCallback.SysManageCancleGWorkFlowTask:
                    {
                        mtGWFTask wfTask = new mtGWFTask();

                        sc.serialize(wfTask);

                        m_pHost.RunEnv.UpdateGWorkFlowTask(wfTask);

                        ec = m_pCallback.OnCancleGWorkFlowTask(wfTask);
                    }
                    break;
                case ImtSysManageCallback.SysManagePublishGSystemStatus:
                    {
                        mtGSystemStatus status = new mtGSystemStatus();

                        sc.serialize(status);

                        m_pHost.RunEnv.UpdateGSystemRunStatus(status);

                        ec = m_pCallback.OnGSystemStatus(status);
                    }
                    break;
                default:
                    return ec;
            }


            return ec;
        }

       
    }
}
